<%@page import="java.util.Date"%>
<%@page import="entity.Teacher1"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查询整张表</title>
</head>
<body>
<h3 align="center">查询整张表</h3>
<%!
	/**
	*查询性别
	*@return
	*
	*/
	public String getSex(String Idcard){
		String sex;
		if(Integer.parseInt(Idcard.substring(16, 17))%2==0){
		sex="女";
	}else{
		sex="男";
	}
	return sex;
	}
	/**
	*
	*@return
	*/
	public int getAge(String Idcard){
		String year=Idcard.substring(6, 10);
		int y=Integer.parseInt(year);
		Date d=new Date();
		int currYear=d.getYear()+1900;
		return currYear-y;
	}
	
	public String getBirth(String Idcard){
		String year=Idcard.substring(6, 10);
		String month=Idcard.substring(10, 12);
		String day=Idcard.substring(12, 14);
		return year+"-"+month+"-"+day;
	}
 %>
<table border="1" align="center">

	<tr>
		<td align="center">工号</td>
		<td align="center">姓名</td>
		<td align="center">性别</td>
		<td align="center">年龄</td>
		<td align="center">身份证</td>
		<td align="center">生日</td>
		<td align="center">院系</td>
		<td align="center">电话号码</td>
	</tr>
<%
	List<Teacher1> list=(List<Teacher1>)session.getAttribute("listQuery");
	for(int i=0;i<list.size();i++){
		Teacher1 t=list.get(i);
 %>
 	<tr>
 		<td align="center"><%=t.getId() %></td>
 		<td align="center"><%=t.getName() %></td>
 		<td align="center"><%=this.getSex(t.getIdcard()) %></td>
 		<td align="center"><%=this.getAge(t.getIdcard()) %></td>
 		<td align="center"><%=t.getIdcard() %></td>
 		<td align="center"><%=this.getBirth(t.getIdcard()) %></td>
 		<td align="center"><%=t.getDepartment() %></td>
 		<td align="center"><%=t.getPhone() %></td>
 	</tr>
 <%} %>
 </table>
</body>
</html>